package com.suyun.service.impl;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.suyun.dao.OrderDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
@Slf4j
public class OrderServiceImpl3 {


    @SentinelResource(value = "message",//指明资源名称
        blockHandler = "blockHandler",  //发生BlockException时进入的方法
        blockHandlerClass = OrderServiceImpl3BlockHandler.class,
        fallback = "fallback",
        fallbackClass = OrderServiceImpl3FallBackHandler.class)  //发生Throwable时进入的方法
    public String message(String name){
        return "message";
    }


    /**
     * 该方法需要和message方法返回这和参数一致，但可以在最后加异常参数  可以将这两方法挪到外部，但是需要加static
     * @param name
     * @return
     */
    /*public String blockHandler(String name, BlockException e){
        log.info("触发了 BlockException {}",e);
        return "BlockException";
    }*/


    /*public String fallback(String name, Throwable e){
        log.info("触发了 fallback {}",e);
        return "fallback";
    }*/

}
